package com.binary.coder.gift.core.interfaces.ai.facade;

import com.alibaba.fastjson.JSON;
import com.binary.coder.gift.core.common.bean.ResultBean;
import com.binary.coder.gift.core.common.constant.ConversationType;
import com.binary.coder.gift.core.domain.ai.AiService;
import com.binary.coder.gift.core.domain.ai.factory.AiFactory;
import io.swagger.annotations.Api;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @author atao
 * @version 1.0.0
 * @ClassName AiController.java
 * @Description AI模型
 * @createTime 2024年07月11日 16:23:00
 */
@Api(tags = "AI大模型相关接口")
@RestController
@RequestMapping("/api/ai/")
public class AiController {

    @Resource
    private AiFactory aiFactory;

    @PostMapping("/test")
    public ResultBean<String> test(@RequestParam("model")String model, @RequestParam("message")String message) {
        AiService aiServiceByTypeCode = aiFactory.getAiServiceByTypeCode(model);
        return ResultBean.success(JSON.toJSONString(aiServiceByTypeCode.processConversation(ConversationType.TEXT,message)));
    }

}
